#!/bin/bash

#-------------------------------------------------------------------------------

sources=src

#-------------------------------------------------------------------------------

function copy_ordinary()
{
	mkdir -p ~/.dicodor/dics/ns{,-merged}
	cp -f $sources/dics/ns/{a,b,c,d}.dic ~/.dicodor/dics/ns
}

#-------------------------------------------------------------------------------

function copy_shared()
{
	mkdir -p /usr/share/dicodor/ns{,-merged}
	cp -f $sources/dics/*.dic           /usr/share/dicodor/
	cp -f $sources/dics/ns/*.dic        /usr/share/dicodor/ns
	cp -f $sources/dics/ns-merged/*.dic /usr/share/dicodor/ns-merged
}

#-------------------------------------------------------------------------------

function syntaxe()
{
	cat <<- END
	usage : 
	  $0
	  $0 --shared
	END
	exit 1
}

#-------------------------------------------------------------------------------

if [ $# -eq 0 ]; then
	copy_ordinary
	exit 0
fi

#-------------------------------------------------------------------------------

case $1 in
	--su-shared) copy_shared;                           ;;
	--shared)    copy_ordinary; su -c "$0 --su-shared"; ;;
	--help)      syntaxe;                               ;;
	*)           syntaxe;                               ;;
esac

exit 0

#-------------------------------------------------------------------------------

